package guda.house.dal.dao.impl;

import guda.grape.autogen.common.BaseDAO;
import guda.house.dal.dao.BuildingDAO;
import guda.house.dal.dataobject.BuildingDO;
import guda.grape.autogen.common.page.BaseQuery;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BuildingDAOImpl extends BaseDAO implements BuildingDAO {

    @Override
	public Long insert(BuildingDO building) {
	      try {
                return (Long) getSqlMapperW().insert("building.insert",building);
          } catch (Exception e) {
                throw new RuntimeException(e);
          }

	}

    @Override
	public BuildingDO getBuildingById(Long buildingId) {
	    return (BuildingDO)getSqlMapClientTemplate().queryForObject("building.getBuildingById", buildingId);
	}

    @Override
	public boolean delBuildingById(Long buildingId) {
	    int num = 0;
        try {
            num = getSqlMapperW().delete("building.delBuildingById",buildingId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if(num>0){
            return true;
        }else{
            return false;
        }
	}

    @Override
	public List<BuildingDO> getBuildingByIds(List idsList) {
        Map m = new HashMap();
        m.put("idsList",idsList);
		return getSqlMapClientTemplate().queryForList("building.selectByIds", m);
	}

    @Override
	public void cleanAutoIncrement(Long buildingId) {
	    try {
            getSqlMapperW().update("building.cleanAutoIncrement",buildingId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
	}

    @Override
    public List<BuildingDO> selectForPage(BaseQuery baseQuery) {
        return getSqlMapClientTemplate().queryForList("building.selectForPage", baseQuery);
    }

    @Override
    public int countForPage(BaseQuery baseQuery) {
        return (Integer)getSqlMapClientTemplate().queryForObject("building.countForPage",baseQuery);
    }

    @Override
    public void updateByIdSelective(BuildingDO building) {
        try {
            getSqlMapperW().update("building.updateByIdSelective",building);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

